//
//  macro.h
//  Pods
//
//  Created by sxh on 2020/10/3.
//

#ifndef macro_h
#define macro_h

#import "UIDevice+SXHDeviceFrame.h"

#define kScreenWidth [UIScreen mainScreen].bounds.size.width
#define kScreenHeight [UIScreen mainScreen].bounds.size.height

#define kIS_iphone (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define kIS_iPhoneX kScreenWidth >=375.0f && kScreenHeight >=812.0f&& kIS_iphone


/*状态栏高度*/
#define kStatusBarHeight ([UIDevice dev_statusBarHeight])
/*导航栏高度*/
#define kNavBarHeight ([UIDevice dev_navigationBarHeight])
/*状态栏和导航栏总高度*/
#define kNavBarAndStatusBarHeight ([UIDevice dev_navigationFullHeight])
/*TabBar高度*/
#define kTabBarHeight ([UIDevice dev_tabBarFullHeight])
/*顶部安全区域远离高度*/
#define kTopBarSafeHeight ([UIDevice dev_safeDistanceTop])
 /*底部安全区域远离高度*/
#define kBottomSafeHeight ([UIDevice dev_safeDistanceBottom])
/*iPhoneX的状态栏高度差值*/
#define kTopBarDifHeight (CGFloat)(kIS_iPhoneX?(24.0):(0))
/*导航条和Tabbar总高度*/
#define kNavAndTabHeight (kNavBarAndStatusBarHeight + kTabBarHeight)

#define DT_IS_IPHONEX_XS   (IPHONE_HEIGHT == 812.f)  //是否是iPhoneX、iPhoneXS
#define DT_IS_IPHONEXR_XSMax   (IPHONE_HEIGHT == 896.f)  //是否是iPhoneXR、iPhoneX Max
#define IS_IPHONEX_SET  (DT_IS_IPHONEX_XS||DT_IS_IPHONEXR_XSMax)  //是否是iPhoneX系列手机
#define IS_IPHONE14 (IPHONE_HEIGHT == 932.f||IPHONE_HEIGHT == 852.f) // 14系列 顶部安全区47px
#define IS_IPHONE_14PRO (IPHONE_HEIGHT == 926.f||IPHONE_HEIGHT == 844.f) // 14pro系列 顶部安全区59px

/*文件目录相关*/
#define kLibraryDirectory [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) firstObject]
#define kDocumentDirectory [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]
/*不同模块的文档目录*/
#define kDocDirectory(agreementName, appid) [NSString stringWithFormat:@"%@/%@/%@/doc",kLibraryDirectory,agreementName,appid]
/*不同模块的下载目录*/
#define kDownloadDirectory(agreementName, appid) [NSString stringWithFormat:@"%@/%@/%@/download",kLibraryDirectory,agreementName,appid]
/*不同模块的APP访问*/
#define kWidgetDirectory(agreementName, appid) [NSString stringWithFormat:@"%@/%@/%@/widget",kLibraryDirectory,agreementName,appid]
/*不同模块的备份目录*/
#define kBackupDirectory(agreementName, appid) [NSString stringWithFormat:@"%@/%@/%@/widget_backup",kLibraryDirectory,agreementName,appid]
/*bundle中对应appid的文件目录*/
#define kBundleWidget(appid) kBundleWidgets(@"widget",appid)
#define kBundleWidgets(referenceFileName, appid) [NSString stringWithFormat:@"%@/%@/%@",[[NSBundle mainBundle] resourcePath],referenceFileName,appid]
/*存数据*/
#define kSetValueForKey(value, key) [[NSUserDefaults standardUserDefaults] setValue:value forKey:key]
/*取数据*/
#define kValueForKey(key) [[NSUserDefaults standardUserDefaults] objectForKey:key]

//weakSelf
#define WS(weakSelf)  __weak __typeof(&*self)weakSelf = self;
//当前app版本号
#define AppVersion [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]

#endif /* macro_h */
